import { Module } from '@nestjs/common';
import { AuthService } from './auth.service';
import { UsersModule } from '../users/user.module';
import { PassportModule } from '@nestjs/passport';
import { JwtModule } from '@nestjs/jwt';
import { AuthController } from '../auth/auth.controller';
import { JwtStrategy } from './jwt.strategy';
import { utilsSecret } from '../utils/index';
import { JWT_SECRET } from "../constant"

// const secretInstance = utilsSecret.Secret.getInit();
// console.log('secretInstance', secretInstance.generateSecretKey());

console.log('JWT_SECRET', JWT_SECRET) 

@Module({
  imports: [
    UsersModule,
    PassportModule.register({ defaultStrategy: 'jwt' }),
    JwtModule.register({
      // secret: secretInstance.generateSecretKey(), // 在生产环境中应该使用环境变量
      // global: true,
      // secret: JWT_SECRET,
      secret: '3a7934ed56223528bb31eeb616394ac6c55bfb2acb63eafe7f6b1868ecd753ac',
      signOptions: { expiresIn: '60h' },
    }),
  ],
  providers: [AuthService, JwtStrategy],
  // providers: [AuthService],
  exports: [JwtModule],
  controllers: [AuthController],
})
export class AuthModule {}